package com.ztgf.shopping.api.client.epg;


import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.ztgf.common.constant.Result;
import com.ztgf.common.enums.CodeEnum;
import com.ztgf.shopping.models.bo.epg.EpgConsultingServiceQueryBO;
import com.ztgf.shopping.models.dto.epg.EpgConsultingServiceDTO;
import com.ztgf.shopping.models.service.epg.IEpgConsultingService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api/epgConsultingServiceApi")
@Api(value = "EpgConsultingServiceApiController", tags = "首页咨询表API接口")
public class EpgConsultingServiceApiController {


    @DubboReference
    private IEpgConsultingService epgConsultingService;


    @PostMapping("/queryPageList")
    @ApiOperation(value = "首页咨询列表", notes = "首页咨询列表")
    public Result<?> queryPageList(EpgConsultingServiceQueryBO queryBO) {
        Wrapper<EpgConsultingServiceDTO> wrapper = new EntityWrapper<>();
        wrapper.eq("status", 0)
                .eq("is_publish", 1)
                .orderBy("sort", true);
        Page<EpgConsultingServiceDTO> page = new Page<>(queryBO.getPageNo(), queryBO.getPageSize());
        page = epgConsultingService.selectPage(page, wrapper);
        return new Result<>(page);
    }

    @PostMapping("/getById")
    @ApiOperation(value = "根据id获取详情", notes = "根据id获取详情")
    public Result<?> getById(Long id) {
        if (id == null) {
            return new Result<>(CodeEnum.FAIL_100002);
        }
        EpgConsultingServiceDTO dto = epgConsultingService.selectById(id);
        return new Result<>(dto);
    }
}
